﻿namespace HySoft.Cash.BaseClass
{
    using Huayou.Common;
    using Huayou.Common.Database;
    using System;
    using System.Data;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public class BaseBusiness : CommonBaseBusiness
    {
        protected Page page;
        public const string SESSION_COMPANY_ID = "Company.ID";
        public const string USERNAME = "UserNameA";
        public const string USERPERM = "UserPerm";
        public const string USERRULE = "UserRule";
        public const string USERSID = "UserSid";

        public BaseBusiness() : base(BaseConfManager.GetDBServer(), BaseConfManager.GetDBName(), BaseConfManager.GetDBUser(), BaseConfManager.GetDBPwd(), int.Parse(BaseConfManager.GetDBType()))
        {
            this.page = null;
            this.page = (Page) HttpContext.Current.Handler;
        }

        public BaseBusiness(DBOperate dbOper) : base(dbOper)
        {
            this.page = null;
            this.page = this.page;
        }

        public BaseBusiness(Page page) : base(BaseConfManager.GetDBServer(), BaseConfManager.GetDBName(), BaseConfManager.GetDBUser(), BaseConfManager.GetDBPwd(), int.Parse(BaseConfManager.GetDBType()))
        {
            this.page = null;
            this.page = page;
        }

        public BaseBusiness(Page page, DBOperate dbOper) : base(dbOper)
        {
            this.page = null;
            this.page = page;
        }

        public static void AutoSetPage(int pageSize, DataGrid dg, DataTable dt)
        {
            dg.PageSize = pageSize;
            CommonBaseBusiness.SetPage(dg, dt);
        }

        public static DBOperate GetDBOperate()
        {
            return DBOperatorFactory.GetDBOperator(BaseConfManager.GetDBServer(), BaseConfManager.GetDBName(), BaseConfManager.GetDBUser(), BaseConfManager.GetDBPwd(), int.Parse(BaseConfManager.GetDBType()));
        }

        public static void SetPage(DataGrid dg, DataTable dt)
        {
            dg.PageSize = 12;
            CommonBaseBusiness.SetPage(dg, dt);
        }
    }
}

